.TH std::chrono::year::operator++,std::chrono::year::operator-- 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::chrono::year::operator++,std::chrono::year::operator-- \- std::chrono::year::operator++,std::chrono::year::operator--

.SH Synopsis
   constexpr std::chrono::year& operator++() noexcept;     \fB(1)\fP \fI(since C++20)\fP
   constexpr std::chrono::year operator++( int ) noexcept; \fB(2)\fP \fI(since C++20)\fP
   constexpr std::chrono::year& operator--() noexcept;     \fB(3)\fP \fI(since C++20)\fP
   constexpr std::chrono::year operator--( int ) noexcept; \fB(4)\fP \fI(since C++20)\fP

   Adds or subtracts 1 from the year value.

   1,2) Performs *this += std::chrono::years{1};.
   3,4) Performs *this -= std::chrono::years{1};.

.SH Parameters

   \fI(none)\fP

.SH Return value

   1,3) A reference to this year after modification.
   2,4) A copy of the year made before modification.

.SH Notes

   If the result would be outside the range [-32767, 32767], the actual stored value is
   unspecified.

.SH Example


// Run this code

 #include <chrono>
 #include <iostream>

 int main()
 {
     std::cout << std::boolalpha;

     std::chrono::year y{2020};
     std::cout << (++y == std::chrono::year(2021)) << ' ';
     std::cout << (--y == std::chrono::year(2020)) << '\\n';

     using namespace std::literals::chrono_literals;
     y = 32767y;
     y++; //← unspecified, see ↑ Notes ↑
     std::cout << static_cast<int>(y) << '\\n';
 }

.SH Possible output:

 true true
 -32768

.SH See also

   operator+= adds or subtracts a number of years from a year
   operator-= \fI(public member function)\fP
   operator+  performs arithmetic on years
   operator-  \fI(function)\fP
   (C++20)
